﻿using System.Web.Mvc;

namespace CID.Web.Support.Ajax
{
    public abstract class AjaxActionResult
    {
        public abstract string Type { get; }

        public static AjaxActionResult Create(ActionResult actionResult, UrlHelper urlHelper)
        {
            AjaxActionResult result = null;
            if (actionResult is ViewResult) result = new AjaxViewResult(actionResult as ViewResult);
            else if (actionResult is RedirectResult) result = new AjaxRedirectResult(actionResult as RedirectResult);
            else if (actionResult is RedirectToRouteResult) result = new AjaxRedirectResult(actionResult as RedirectToRouteResult, urlHelper);
            return result;
        }
    }
}